// JavaScript Document
 /**	-------------------------------------------滑动时头部固定不动------------------ --------------------------------------*/
 var vscroll;
     function loaded(){
	setTimeout(function(){
		vscroll=new iScroll("middle",{
					vScrollbar:false,
					lockDirection:true
				});		
		vscroll.refresh(); 
	},1);
}
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);

document.addEventListener('DOMContentLoaded', loaded, false);

$(document).ready(function(e) {
    setTimeout(function(){
		$("#middle").height($(window).height()-$("#top").height())
		vscroll.refresh();
	},500);
});
/***-------------------------------------------------------------------------------------------------------------------*/
 

  $(document).ready(function() {
	$("#xuanzhong").bind("click",function(){
		$("#xuanzhong").attr("class","xuanzhong");
		$("#weixuanzhong").attr("class","weixuanzhong");
		$("#shaidan").show();
		$("#tuijian").hide();
		
		vscroll.refresh(); 
	});
	$("#weixuanzhong").bind("click",function(){
		$("#xuanzhong").attr("class","weixuanzhong");
		$("#weixuanzhong").attr("class","xuanzhong");
		$("#shaidan").hide();
		$("#tuijian").show();
		vscroll.refresh(); 
	});
	
	$.ajax({
		  url:jsonserver+"community_showOrderList.do?callback=?",
		  type:"POST",
		  data:{"pageSize":"12","pageNo":"1"},
		  dataType:"jsonp",
		  success:function(data){
	       if(data[0].result==1)
						var htm = '';
			var json = data[1].data;
			$(json).each(function(index, element) {
				htm+='<div class="neirong">'+
             '<table width="100%">'+
              '<tr><td width="5%"></td><td class="miaomiao_top">'+element.natureName+'</td></tr>'+
              '<tr>'+
                 '<td width="5%"></td>'+
                 '<td width="20%" nowrap="nowrap"><span class="miaomiao">'+element.singleTime+'</span></td>'+
                 '<td align="left" nowrap="nowrap">'+
                 '<span class="miaomiao_right">&nbsp;&nbsp;推荐了"'+element.businessTypeName+'"业务给'+element.                   customerName+'!</span></td>'+
               '</tr>'+
             '</table>'+
             '</div>';
			 
				if(index<$(json).size()-1){
					htm+='<div class="hengxian"></div>';
				}
            });
			$("#shaidan").html(htm);
			vscroll.refresh(); 
		 }
		  ,error: function(data){
			  JAlert("出问题了。",'系统提示');
		  }  
		});
});
var isloaded=false;
function rr(){
	if(!isloaded){
	$.ajax({
		url:jsonserver+"community_recommendHeroList.do?callback=?",
		dataType:"jsonp",
		data:{"NP_INFO_ID":$.cookie("NP_INFO_ID")},
		success: function(data){
				if(data[0].result=="1"){
				  	var htm='';
				    var json = data[1].data;
					$(json).each(function(index, element) {
                        htm+='<tr id="xunhuan" class="top_b">'+
						'<td align="center">'+
                        '<span class="top_b_lf  mingci_'+index+'"">'+element.ranking+'</span>'+
                       '</td>'+
                       '<td>'+element.username+'</td><td>'+element.singlenum+'</td>'+
					   '</tr>';
					   if(element.flag=="0"){
						   $("#mingci").html("太棒了！您当前是第"+element.ranking+"名哦~");
						}
                    });	
				}
			   $("#xunhuan").append(htm);
			   isloaded = true;
			   vscroll.refresh(); 
		},
		error: function(){
			  JAlert("出问题了。",'系统提示');
		 }
		});
			
	}
		/**
		
		
			var htm = '';
			var json = data[1].data;
			$(json).each(function(index, element) {
			   alert(element.username[0]);
			htm+='<div id="tuijian" style="display:none; width:100%" align="center">'+
			 '<tr class="top_b">'+
                       '<td align="center">'+
                        '<span class="top_b_lf">'+element.ranking+'</span>'+
                       '</td>'+
                       '<td>'+element.username+'</td><td>'+element.singlenum +'</td>'+
                     '</tr>'+
			'</div>';
            });
			$("#xunhuan").html(htm);
		*/
}
$("#weixuanzhong").attr("onclick",function(){
	
function btn_back_click(){
	history.goback(-1);	
}	
	
});